﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel; 
using NTTDATA.BEENChina.ResultCertification.Config;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil.CustomObject;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Select
{
   
    [Serializable]
    [VerfityAttribute(Id = "VerfityS0002", Name = "第N行N列選択有/无记载", CategoryType = EnumCategoryType.选择, Model = true)]
    public class VerfityS0002 : VerfityOneResult
    { 
        private CustomCollection<DataExists> _datalist = new CustomCollection<DataExists>() { Description = "指定数据列表" };

        [Category("指定数据列表"), Description("输入指定数据项目")]
        [TypeConverter(typeof(CustomCollectionConverter<DataExists>))]
        [RefreshProperties(RefreshProperties.All)]
        public CustomCollection<DataExists> SpecialDataList
        {
            get { return _datalist; }
            //set { _rangelist = value; }
        }

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;
            if (result == null)
            {
                return false;
            }

            if (entryCommon.Equals("30") ||
                EntryResultIsEmpty(result))
            {
                return false;
            }

            bresult = SpecialDataList.Select(t => t.Group).Distinct()
                                  .Any(g => SpecialDataList.Where(t => t.Group.Equals(g))
                                  .All(o => CheckSpecificRowIsEmpty(result, GetSpeicficResult, o.Exists, o.Row, o.Col)));


            if (bresult)
            {
                System.Console.WriteLine("VerfityS0002");
            }

            return bresult;
        }

        protected   string GetSpeicficResult(string colStr)
        {
            var splitEntryResult =
                new Split.SplitEntryResult(
                    ChildImageObject.CategorySetting.DataFormat, colStr);
            var mdRsult = splitEntryResult.GetSelect();

            return mdRsult;
        }       
    }
}
